-
Notifications
You must be signed in to change notification settings - Fork 690
Schedule job for cleanup data #1106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schedule job for cleanup data #1106
Conversation
This script contains two parts, 1st part is client script and 2nd part is script include.. and this helps to lock the file till the developer completes his development, so that we can avoid concurrency issues. Ex: If a "Developer A" working on "Widget A", parallelly if "Developer B" working on "Widget B", then if Developer B moves the code to higher environment before developer A completes his development.. so it creates an issue.. to avoid these kind of concurrency issues.. we can use locking system for each record.. in the above script I shown example for widget records.
Calculate the time difference between incident creation and change implementation
…ty and the assignment group's working hours directory
…creation and related change implementation directory
This script automates the cleanup of old closed incidents in the ServiceNow instance. It helps maintain a clean and efficient database by removing records that are no longer needed, thereby improving system performance and manageability.
This readme file helps to understand what the code exactly going to do.
@ynr-ram Thanks for your contribution. But, did you consider impact of this script? if closed incidents older than 90 days are deleted, what about cascade delete and records related to these incidents? You may get into broken referenced records. also, this same feature can be completed without code using flow designer. |
I am closing this following the previous comment, especially considering that the script itself has little added value in its current form. However, if you were to expand your script following for instance Sachin's suggestions, we would be happy to accept it. |
Overview
This script automates the cleanup of old closed incidents in the ServiceNow instance. It helps maintain a clean and efficient database by removing records that are no longer needed, thereby improving system performance and manageability.
Features
Automatic Cleanup: Deletes closed incidents that are older than 90 days.
Customizable Timeframe: Easily adjustable parameters to change the age of incidents for cleanup.
Logging: Outputs the number of incidents deleted to the system logs for tracking purposes.
Prerequisites
Access to a ServiceNow instance with appropriate permissions to run scripts.
Knowledge of how to create Scheduled Jobs in ServiceNow.
Installation
Create a New Scheduled Job:
Navigate to System Definition > Scheduled Jobs in your ServiceNow instance.
Click on New to create a new Scheduled Job.
Configure the Job:
Name: Enter a descriptive name for the job, e.g., "Cleanup Old Closed Incidents."
Run: Set the desired schedule for when you want the job to run (e.g., daily, weekly).
Script: Copy and paste the provided script into the script section of the Scheduled Job.